package models

import (
	"github.com/jinzhu/gorm"
	"log"
	"time"
)

type User struct {
	Id        int       `gorm:"column:id;primary_key" json:"id"`
	Name      string    `gorm:"default:'galeone'"`
	Age       int64     `gorm:"column:age"`
	Score     float64   `gorm:"column:score"`
	CreatedAt time.Time `gorm:"column:created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at"`
}

func UpdateLimitOne(scope *gorm.Scope) {
	log.Println("Update Hook ....")
	scope.Search.Limit(1)
}

func (u *User) TableName() string {
	return "user"
}

type Animal struct {
	ID         int64
	Name       string `gorm:"default:'galeone'"`
	Age        int64
	Created_At time.Time
	Updated_at time.Time
}

func (u *Animal) TableName() string {
	return "animal"
}
